home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Tele / C / Comet2.1.3.cpt / emlib / macinit.c < prev    next >
Text File  |  1991-06-25  |  2KB  |  121 lines

  1. /*
  2.     Copyright Cornell University 1986.  All rights are reserved.
  3.  
  4.     As of 4/10/86:
  5.     This source file may have no changes from the M.I.T original
  6.     other than this notice; but it has been tested as part of 
  7.     Cornell's Aztec-C port.  See notice.h
  8. */
  9.  
  10. /*    macinit.c initializes the most general mac interfaces */
  11.  
  12. #include    <em.h>
  13. #include    <inits.h>
  14. #include    <memory.h>
  15.  
  16. #include    <h19.h>
  17. #include    <macdefs.h>
  18.  
  19. #define NUMMASTERS    10
  20.  
  21.  
  22. /* 
  23.  *  Initialize macintosh fundamentals:  memory, screen
  24.  */
  25.  
  26.  
  27. macinit(allocsize)
  28.    long allocsize;
  29. {
  30.     char        *bptr;
  31.     int count;
  32.     
  33. #ifdef NOSCRDMP
  34. /* variable address for disabling system trap of top row command-shift keys */
  35.     char * ScrDmpEnb = 0x2f8;
  36.  
  37.     *ScrDmpEnb = 0;        
  38.         /* disables command-shift-number trap; this means the event mgr 
  39.          * will no longer do screen dumps 
  40.          */
  41. #endif
  42.  
  43.     bptr = (char *) NewPtr(allocsize);
  44.     if (bptr == (char *) NULL) {
  45.        SysBeep(5);
  46.     }
  47.     else {
  48.        DisposPtr(bptr);
  49.     }
  50.  
  51.     MaxApplZone();  
  52.  
  53.     for (count = NUMMASTERS; count--; ) {
  54.         MoreMasters();
  55.     }
  56.  
  57.     InitGraf(&thePort);
  58.     InitFonts();
  59.     InitWindows();
  60.     InitMenus();
  61.     TEInit();
  62.     InitDialogs((ProcPtr) NULL);
  63.     InitCursor();
  64.  
  65.     keyinit();            /* change the key mapping for e i n u */
  66.     
  67.     globalconfig();
  68.  
  69. #ifdef SETGROWZONE
  70.     /* Doesn't work under MF */
  71.     /* allocate a grow block and set our grow zone function */
  72.     {
  73.         extern pascal long growzone();
  74.         
  75.         growblock = NewHandle(GROWBLOCKSIZE);
  76.         SetGrowZone(growzone);
  77.     }
  78. #endif
  79. }
  80.  
  81.  
  82. #ifdef SETGROWZONE
  83.  
  84. #define GROWBLOCKSIZE    6000        /* leave size zero unless need demonstrated */
  85.  
  86. Handle growblock;                /* Handle to memory to free up */
  87.  
  88. pascal long growzone(growsize)
  89. long growsize;
  90. {
  91.     static long growleft = GROWBLOCKSIZE;
  92.     
  93.     if (*GZRootHnd != NULL) {
  94.         HLock(GZRootHnd);
  95.     }
  96.     if (growleft < growsize) {
  97.         growsize = growleft;
  98.         if (growleft)
  99.             DisposHandle(growblock);
  100.         growleft = 0;
  101.     }
  102.     else {
  103.         growleft -= growsize;
  104.         SetHandleSize(growblock, growleft);
  105.     }
  106.     if (*GZRootHnd != NULL) {
  107.         HUnlock(GZRootHnd);
  108.     }
  109.     if (growleft < 5000) {
  110.         pr25(0, "You're VERY short of memory!");
  111.     }
  112.     else {
  113.         prerr25("You're running short of memory!");
  114.     }
  115.     return(growsize);
  116. }
  117.  
  118.  
  119.  
  120. #endif
  121.